package com.ksm.web.controller.version;


import com.ksm.common.core.domain.AjaxResult;
import com.ksm.version.domain.vo.FileVo;
import com.ksm.version.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class FileController {


    @Autowired
    private FileService service;

    @PostMapping("/api/localStorage")
    public AjaxResult fileUploads(@RequestParam("file") MultipartFile file) throws IOException {
        // 待完成 —— 文件类型校验工作
        return AjaxResult.success(service.add(file));
    }


    @PostMapping("/api/uploadApp")
    public AjaxResult fileUploadPackage(@RequestBody FileVo fileVo) {
        return AjaxResult.success(service.updatePackage(fileVo));
    }
}
